import {get,post} from '../../utils/request'
const state={
  //用来保存查询出来的栏目信息
  categorys:[],
  total:0
}

const actions={
  //查询所有栏目信息
  findAllCategory(context,list){
    //异步操作
    get('/baseUser/pageQuery',list).then(res=>{
      
      let response=res.data.list
      context.commit('setCategorys',response)
      let total=res.data.total
      context.commit('setTotal',total)
    })
  },

  //保存栏目信息
  saveCategory(context,list){       
    let respone=post('/baseUser/saveOrUpdate',list)
    return respone
  },

  //删除栏目信息
  deleteCategory(context,list){
    let respone=get('/baseUser/deleteById',list)
    return respone
  },
  //查看栏目信息
  detailsCategory(context,list){
    let respone=get('/baseUser/findUserDetailsById',list)
    return respone
  }
}

const mutations={
  //修改state中的值
  setCategorys(state,response){
    state.categorys=response
  },
  setTotal(state,total){
    state.total=total
  }
}

export default{
  namespaced:true,
  state,
  actions,
  mutations
}